home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 83 / MacAddict_083_2003-07.iso / mac / Software / Development / VLC Source 0.5.3.dmg / m4 / lib-link.m4 < prev    next >
Text File  |  2003-03-25  |  23KB  |  555 lines

  1. # lib-link.m4 serial 3 (gettext-0.11.3)
  2. dnl Copyright (C) 2001-2002 Free Software Foundation, Inc.
  3. dnl This file is free software, distributed under the terms of the GNU
  4. dnl General Public License.  As a special exception to the GNU General
  5. dnl Public License, this file may be distributed as part of a program
  6. dnl that contains a configuration script generated by Autoconf, under
  7. dnl the same distribution terms as the rest of that program.
  8.  
  9. dnl From Bruno Haible.
  10.  
  11. dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
  12. dnl the libraries corresponding to explicit and implicit dependencies.
  13. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
  14. dnl augments the CPPFLAGS variable.
  15. AC_DEFUN([AC_LIB_LINKFLAGS],
  16. [
  17.   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  18.   AC_REQUIRE([AC_LIB_RPATH])
  19.   define([Name],[translit([$1],[./-], [___])])
  20.   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
  21.                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
  22.   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
  23.     AC_LIB_LINKFLAGS_BODY([$1], [$2])
  24.     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
  25.     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
  26.     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
  27.   ])
  28.   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
  29.   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
  30.   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
  31.   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
  32.   AC_SUBST([LIB]NAME)
  33.   AC_SUBST([LTLIB]NAME)
  34.   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
  35.   dnl results of this search when this library appears as a dependency.
  36.   HAVE_LIB[]NAME=yes
  37.   undefine([Name])
  38.   undefine([NAME])
  39. ])
  40.  
  41. dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
  42. dnl searches for libname and the libraries corresponding to explicit and
  43. dnl implicit dependencies, together with the specified include files and
  44. dnl the ability to compile and link the specified testcode. If found, it
  45. dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
  46. dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
  47. dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
  48. dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
  49. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
  50. [
  51.   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  52.   AC_REQUIRE([AC_LIB_RPATH])
  53.   define([Name],[translit([$1],[./-], [___])])
  54.   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
  55.                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
  56.  
  57.   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
  58.   dnl accordingly.
  59.   AC_LIB_LINKFLAGS_BODY([$1], [$2])
  60.  
  61.   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
  62.   dnl because if the user has installed lib[]Name and not disabled its use
  63.   dnl via --without-lib[]Name-prefix, he wants to use it.
  64.   ac_save_CPPFLAGS="$CPPFLAGS"
  65.   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
  66.  
  67.   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
  68.     ac_save_LIBS="$LIBS"
  69.     LIBS="$LIBS $LIB[]NAME"
  70.     AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
  71.     LIBS="$ac_save_LIBS"
  72.   ])
  73.   if test "$ac_cv_lib[]Name" = yes; then
  74.     HAVE_LIB[]NAME=yes
  75.     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
  76.     AC_MSG_CHECKING([how to link with lib[]$1])
  77.     AC_MSG_RESULT([$LIB[]NAME])
  78.   else
  79.     HAVE_LIB[]NAME=no
  80.     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
  81.     dnl $INC[]NAME either.
  82.     CPPFLAGS="$ac_save_CPPFLAGS"
  83.     LIB[]NAME=
  84.     LTLIB[]NAME=
  85.   fi
  86.   AC_SUBST([HAVE_LIB]NAME)
  87.   AC_SUBST([LIB]NAME)
  88.   AC_SUBST([LTLIB]NAME)
  89.   undefine([Name])
  90.   undefine([NAME])
  91. ])
  92.  
  93. dnl Determine the platform dependent parameters needed to use rpath:
  94. dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
  95. dnl hardcode_direct, hardcode_minus_L,
  96. dnl sys_lib_search_path_spec, sys_lib_dlsearch_path_spec.
  97. AC_DEFUN([AC_LIB_RPATH],
  98. [
  99.   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
  100.   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
  101.   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
  102.   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
  103.   AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
  104.     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
  105.     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
  106.     . ./conftest.sh
  107.     rm -f ./conftest.sh
  108.     acl_cv_rpath=done
  109.   ])
  110.   wl="$acl_cv_wl"
  111.   libext="$acl_cv_libext"
  112.   shlibext="$acl_cv_shlibext"
  113.   hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
  114.   hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
  115.   hardcode_direct="$acl_cv_hardcode_direct"
  116.   hardcode_minus_L="$acl_cv_hardcode_minus_L"
  117.   sys_lib_search_path_spec="$acl_cv_sys_lib_search_path_spec"
  118.   sys_lib_dlsearch_path_spec="$acl_cv_sys_lib_dlsearch_path_spec"
  119.   dnl Determine whether the user wants rpath handling at all.
  120.   AC_ARG_ENABLE(rpath,
  121.     [  --disable-rpath         do not hardcode runtime library paths],
  122.     :, enable_rpath=yes)
  123. ])
  124.  
  125. dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
  126. dnl the libraries corresponding to explicit and implicit dependencies.
  127. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
  128. AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
  129. [
  130.   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
  131.                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
  132.   dnl By default, look in $includedir and $libdir.
  133.   use_additional=yes
  134.   AC_LIB_WITH_FINAL_PREFIX([
  135.     eval additional_includedir=\"$includedir\"
  136.     eval additional_libdir=\"$libdir\"
  137.   ])
  138.   AC_ARG_WITH([lib$1-prefix],
  139. [  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
  140.   --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
  141. [
  142.     if test "X$withval" = "Xno"; then
  143.       use_additional=no
  144.     else
  145.       if test "X$withval" = "X"; then
  146.         AC_LIB_WITH_FINAL_PREFIX([
  147.           eval additional_includedir=\"$includedir\"
  148.           eval additional_libdir=\"$libdir\"
  149.         ])
  150.       else
  151.         additional_includedir="$withval/include"
  152.         additional_libdir="$withval/lib"
  153.       fi
  154.     fi
  155. ])
  156.   dnl Search the library and its dependencies in $additional_libdir and
  157.   dnl $LDFLAGS. Using breadth-first-seach.
  158.   LIB[]NAME=
  159.   LTLIB[]NAME=
  160.   INC[]NAME=
  161.   rpathdirs=
  162.   ltrpathdirs=
  163.   names_already_handled=
  164.   names_next_round='$1 $2'
  165.   while test -n "$names_next_round"; do
  166.     names_this_round="$names_next_round"
  167.     names_next_round=
  168.     for name in $names_this_round; do
  169.       already_handled=
  170.       for n in $names_already_handled; do
  171.         if test "$n" = "$name"; then
  172.           already_handled=yes
  173.           break
  174.         fi
  175.       done
  176.       if test -z "$already_handled"; then
  177.         names_already_handled="$names_already_handled $name"
  178.         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
  179.         dnl or AC_LIB_HAVE_LINKFLAGS call.
  180.         uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
  181.         eval value=\"\$HAVE_LIB$uppername\"
  182.         if test -n "$value"; then
  183.           if test "$value" = yes; then
  184.             eval value=\"\$LIB$uppername\"
  185.             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
  186.             eval value=\"\$LTLIB$uppername\"
  187.             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
  188.           else
  189.             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
  190.             dnl that this library doesn't exist. So just drop it.
  191.             :
  192.           fi
  193.         else
  194.           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
  195.           dnl and the already constructed $LIBNAME/$LTLIBNAME.
  196.           found_dir=
  197.           found_la=
  198.           found_so=
  199.           found_a=
  200.           if test $use_additional = yes; then
  201.             if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
  202.               found_dir="$additional_libdir"
  203.               found_so="$additional_libdir/lib$name.$shlibext"
  204.               if test -f "$additional_libdir/lib$name.la"; then
  205.                 found_la="$additional_libdir/lib$name.la"
  206.               fi
  207.             else
  208.               if test -f "$additional_libdir/lib$name.$libext"; then
  209.                 found_dir="$additional_libdir"
  210.                 found_a="$additional_libdir/lib$name.$libext"
  211.                 if test -f "$additional_libdir/lib$name.la"; then
  212.                   found_la="$additional_libdir/lib$name.la"
  213.                 fi
  214.               fi
  215.             fi
  216.           fi
  217.           if test "X$found_dir" = "X"; then
  218.             for x in $LDFLAGS $LTLIB[]NAME; do
  219.               AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  220.               case "$x" in
  221.                 -L*)
  222.                   dir=`echo "X$x" | sed -e 's/^X-L//'`
  223.                   if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
  224.                     found_dir="$dir"
  225.                     found_so="$dir/lib$name.$shlibext"
  226.                     if test -f "$dir/lib$name.la"; then
  227.                       found_la="$dir/lib$name.la"
  228.                     fi
  229.                   else
  230.                     if test -f "$dir/lib$name.$libext"; then
  231.                       found_dir="$dir"
  232.                       found_a="$dir/lib$name.$libext"
  233.                       if test -f "$dir/lib$name.la"; then
  234.                         found_la="$dir/lib$name.la"
  235.                       fi
  236.                     fi
  237.                   fi
  238.                   ;;
  239.               esac
  240.               if test "X$found_dir" != "X"; then
  241.                 break
  242.               fi
  243.             done
  244.           fi
  245.           if test "X$found_dir" != "X"; then
  246.             dnl Found the library.
  247.             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
  248.             if test "X$found_so" != "X"; then
  249.               dnl Linking with a shared library. We attempt to hardcode its
  250.               dnl directory into the executable's runpath, unless it's the
  251.               dnl standard /usr/lib.
  252.               if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
  253.                 dnl No hardcoding is needed.
  254.                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  255.               else
  256.                 dnl Use an explicit option to hardcode DIR into the resulting
  257.                 dnl binary.
  258.                 dnl Potentially add DIR to ltrpathdirs.
  259.                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
  260.                 haveit=
  261.                 for x in $ltrpathdirs; do
  262.                   if test "X$x" = "X$found_dir"; then
  263.                     haveit=yes
  264.                     break
  265.                   fi
  266.                 done
  267.                 if test -z "$haveit"; then
  268.                   ltrpathdirs="$ltrpathdirs $found_dir"
  269.                 fi
  270.                 dnl The hardcoding into $LIBNAME is system dependent.
  271.                 if test "$hardcode_direct" = yes; then
  272.                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
  273.                   dnl resulting binary.
  274.                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  275.                 else
  276.                   if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
  277.                     dnl Use an explicit option to hardcode DIR into the resulting
  278.                     dnl binary.
  279.                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  280.                     dnl Potentially add DIR to rpathdirs.
  281.                     dnl The rpathdirs will be appended to $LIBNAME at the end.
  282.                     haveit=
  283.                     for x in $rpathdirs; do
  284.                       if test "X$x" = "X$found_dir"; then
  285.                         haveit=yes
  286.                         break
  287.                       fi
  288.                     done
  289.                     if test -z "$haveit"; then
  290.                       rpathdirs="$rpathdirs $found_dir"
  291.                     fi
  292.                   else
  293.                     dnl Rely on "-L$found_dir".
  294.                     dnl But don't add it if it's already contained in the LDFLAGS
  295.                     dnl or the already constructed $LIBNAME
  296.                     haveit=
  297.                     for x in $LDFLAGS $LIB[]NAME; do
  298.                       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  299.                       if test "X$x" = "X-L$found_dir"; then
  300.                         haveit=yes
  301.                         break
  302.                       fi
  303.                     done
  304.                     if test -z "$haveit"; then
  305.                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
  306.                     fi
  307.                     if test "$hardcode_minus_L" != no; then
  308.                       dnl FIXME: Not sure whether we should use
  309.                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
  310.                       dnl here.
  311.                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
  312.                     else
  313.                       dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
  314.                       dnl here, because this doesn't fit in flags passed to the
  315.                       dnl compiler. So give up. No hardcoding. This affects only
  316.                       dnl very old systems.
  317.                       dnl FIXME: Not sure whether we should use
  318.                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
  319.                       dnl here.
  320.                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
  321.                     fi
  322.                   fi
  323.                 fi
  324.               fi
  325.             else
  326.               if test "X$found_a" != "X"; then
  327.                 dnl Linking with a static library.
  328.                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
  329.               else
  330.                 dnl We shouldn't come here, but anyway it's good to have a
  331.                 dnl fallback.
  332.                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
  333.               fi
  334.             fi
  335.             dnl Assume the include files are nearby.
  336.             additional_includedir=
  337.             case "$found_dir" in
  338.               */lib | */lib/)
  339.                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
  340.                 additional_includedir="$basedir/include"
  341.                 ;;
  342.             esac
  343.             if test "X$additional_includedir" != "X"; then
  344.               dnl Potentially add $additional_includedir to $INCNAME.
  345.               dnl But don't add it
  346.               dnl   1. if it's the standard /usr/include,
  347.               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
  348.               dnl   3. if it's already present in $CPPFLAGS or the already
  349.               dnl      constructed $INCNAME,
  350.               dnl   4. if it doesn't exist as a directory.
  351.               if test "X$additional_includedir" != "X/usr/include"; then
  352.                 haveit=
  353.                 if test "X$additional_includedir" = "X/usr/local/include"; then
  354.                   if test -n "$GCC"; then
  355.                     case $host_os in
  356.                       linux*) haveit=yes;;
  357.                     esac
  358.                   fi
  359.                 fi
  360.                 if test -z "$haveit"; then
  361.                   for x in $CPPFLAGS $INC[]NAME; do
  362.                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  363.                     if test "X$x" = "X-I$additional_includedir"; then
  364.                       haveit=yes
  365.                       break
  366.                     fi
  367.                   done
  368.                   if test -z "$haveit"; then
  369.                     if test -d "$additional_includedir"; then
  370.                       dnl Really add $additional_includedir to $INCNAME.
  371.                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
  372.                     fi
  373.                   fi
  374.                 fi
  375.               fi
  376.             fi
  377.             dnl Look for dependencies.
  378.             if test -n "$found_la"; then
  379.               dnl Read the .la file. It defines the variables
  380.               dnl dlname, library_names, old_library, dependency_libs, current,
  381.               dnl age, revision, installed, dlopen, dlpreopen, libdir.
  382.               save_libdir="$libdir"
  383.               case "$found_la" in
  384.                 */* | *\\*) . "$found_la" ;;
  385.                 *) . "./$found_la" ;;
  386.               esac
  387.               libdir="$save_libdir"
  388.               dnl We use only dependency_libs.
  389.               for dep in $dependency_libs; do
  390.                 case "$dep" in
  391.                   -L*)
  392.                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
  393.                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
  394.                     dnl But don't add it
  395.                     dnl   1. if it's the standard /usr/lib,
  396.                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
  397.                     dnl   3. if it's already present in $LDFLAGS or the already
  398.                     dnl      constructed $LIBNAME,
  399.                     dnl   4. if it doesn't exist as a directory.
  400.                     if test "X$additional_libdir" != "X/usr/lib"; then
  401.                       haveit=
  402.                       if test "X$additional_libdir" = "X/usr/local/lib"; then
  403.                         if test -n "$GCC"; then
  404.                           case $host_os in
  405.                             linux*) haveit=yes;;
  406.                           esac
  407.                         fi
  408.                       fi
  409.                       if test -z "$haveit"; then
  410.                         haveit=
  411.                         for x in $LDFLAGS $LIB[]NAME; do
  412.                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  413.                           if test "X$x" = "X-L$additional_libdir"; then
  414.                             haveit=yes
  415.                             break
  416.                           fi
  417.                         done
  418.                         if test -z "$haveit"; then
  419.                           if test -d "$additional_libdir"; then
  420.                             dnl Really add $additional_libdir to $LIBNAME.
  421.                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
  422.                           fi
  423.                         fi
  424.                         haveit=
  425.                         for x in $LDFLAGS $LTLIB[]NAME; do
  426.                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  427.                           if test "X$x" = "X-L$additional_libdir"; then
  428.                             haveit=yes
  429.                             break
  430.                           fi
  431.                         done
  432.                         if test -z "$haveit"; then
  433.                           if test -d "$additional_libdir"; then
  434.                             dnl Really add $additional_libdir to $LTLIBNAME.
  435.                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
  436.                           fi
  437.                         fi
  438.                       fi
  439.                     fi
  440.                     ;;
  441.                   -R*)
  442.                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
  443.                     if test "$enable_rpath" != no; then
  444.                       dnl Potentially add DIR to rpathdirs.
  445.                       dnl The rpathdirs will be appended to $LIBNAME at the end.
  446.                       haveit=
  447.                       for x in $rpathdirs; do
  448.                         if test "X$x" = "X$dir"; then
  449.                           haveit=yes
  450.                           break
  451.                         fi
  452.                       done
  453.                       if test -z "$haveit"; then
  454.                         rpathdirs="$rpathdirs $dir"
  455.                       fi
  456.                       dnl Potentially add DIR to ltrpathdirs.
  457.                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
  458.                       haveit=
  459.                       for x in $ltrpathdirs; do
  460.                         if test "X$x" = "X$dir"; then
  461.                           haveit=yes
  462.                           break
  463.                         fi
  464.                       done
  465.                       if test -z "$haveit"; then
  466.                         ltrpathdirs="$ltrpathdirs $dir"
  467.                       fi
  468.                     fi
  469.                     ;;
  470.                   -l*)
  471.                     dnl Handle this in the next round.
  472.                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
  473.                     ;;
  474.                   *.la)
  475.                     dnl Handle this in the next round. Throw away the .la's
  476.                     dnl directory; it is already contained in a preceding -L
  477.                     dnl option.
  478.                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
  479.                     ;;
  480.                   *)
  481.                     dnl Most likely an immediate library name.
  482.                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
  483.                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
  484.                     ;;
  485.                 esac
  486.               done
  487.             fi
  488.           else
  489.             dnl Didn't find the library; assume it is in the system directories
  490.             dnl known to the linker and runtime loader. (All the system
  491.             dnl directories known to the linker should also be known to the
  492.             dnl runtime loader, otherwise the system is severely misconfigured.)
  493.             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
  494.             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
  495.           fi
  496.         fi
  497.       fi
  498.     done
  499.   done
  500.   if test "X$rpathdirs" != "X"; then
  501.     if test -n "$hardcode_libdir_separator"; then
  502.       dnl Weird platform: only the last -rpath option counts, the user must
  503.       dnl pass all path elements in one option. We can arrange that for a
  504.       dnl single library, but not when more than one $LIBNAMEs are used.
  505.       alldirs=
  506.       for found_dir in $rpathdirs; do
  507.         alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
  508.       done
  509.       dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
  510.       acl_save_libdir="$libdir"
  511.       libdir="$alldirs"
  512.       eval flag=\"$hardcode_libdir_flag_spec\"
  513.       libdir="$acl_save_libdir"
  514.       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
  515.     else
  516.       dnl The -rpath options are cumulative.
  517.       for found_dir in $rpathdirs; do
  518.         acl_save_libdir="$libdir"
  519.         libdir="$found_dir"
  520.         eval flag=\"$hardcode_libdir_flag_spec\"
  521.         libdir="$acl_save_libdir"
  522.         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
  523.       done
  524.     fi
  525.   fi
  526.   if test "X$ltrpathdirs" != "X"; then
  527.     dnl When using libtool, the option that works for both libraries and
  528.     dnl executables is -R. The -R options are cumulative.
  529.     for found_dir in $ltrpathdirs; do
  530.       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
  531.     done
  532.   fi
  533. ])
  534.  
  535. dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
  536. dnl unless already present in VAR.
  537. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
  538. dnl contains two or three consecutive elements that belong together.
  539. AC_DEFUN([AC_LIB_APPENDTOVAR],
  540. [
  541.   for element in [$2]; do
  542.     haveit=
  543.     for x in $[$1]; do
  544.       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
  545.       if test "X$x" = "X$element"; then
  546.         haveit=yes
  547.         break
  548.       fi
  549.     done
  550.     if test -z "$haveit"; then
  551.       [$1]="${[$1]}${[$1]:+ }$element"
  552.     fi
  553.   done
  554. ])
  555.